<!DOCTYPE html>
<html lang="en" style="overflow:hidden">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>viewer</title>
</head>
<body>
<script src="lib/three.js" type="text/javascript"></script>
<script src="./lib/xml2json.min.js"> </script>
<script src="./assets/sxb/sxbFiles.js"> </script>
<script src="./assets/sxb/startnametoid.js"> </script>
<script src="./assets/sxb/starlinelimit.js"> </script>
<script src="./lib/starlineprocess.js"> </script>
<!-- <script src="./lib/fileserver.js"> </script> -->
<script>

    function loadXMLDoc(dname)
	{
	  var  xhttp;
	  if(window.XMLHttpRequest){
	   xhttp = new  XMLHttpRequest();
	  }
	  else{
	    xhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  
	  xhttp.open("GET",dname,false);
	  xhttp.send();
	  return xhttp.responseXML;
	}
	
	var jsonObjecs = [];
	var x2js = new X2JS();
	var files  = window.sxbfiles.files;
	for(var i = 0 ;i< files.length;i++)
	{
	  var xmlDoc2 = loadXMLDoc("./assets/sxb/"+files[i]);
	  var jesonObj = x2js.xml2json(xmlDoc2);
	  jsonObjecs.push(jesonObj);
	}
	
	//当前的数据以分钟计算时间
	var outDataTime = 1.0;
	 //当前的数据以秒计算时间
	var timeRecordDelte = 60.0;
	var timeStarDelta = 3.0;
	

	if(jsonObjecs.length != 0){
        
		 var tableCount = jsonObjecs[0].相控阵时隙表.表数量;

		for(var j = 0;j< tableCount;j++){
		
		    var starlines = new StartLineS();
			
			for(var i = 0;i< jsonObjecs.length;i++){
			
				var tableRoot = jsonObjecs[i].相控阵时隙表;
				var tableCount = tableRoot.表数量;
				var starSCID = parseInt(tableRoot.本星SCID)-192;
				if(starSCID < 1)
				{
				   continue;
				}
	
				var table = tableRoot.Table[j];
				var tableSS = parseInt(table.有效SOW);
				var tableSE = parseInt(table.无效SOW);
				var tableRecord = table.record;
				var tableTime = parseInt(table.有效WN);
				var recordCount = tableRecord.length;
				var time = tableSS;
				
				 //先把所有卫星之间的链接关系根据是否有重复，进行添加
			   for(var k = 0;k < recordCount;k++){
				   var record = tableRecord[k];
				   var recordSCID = parseInt(record.SCID)-192;
				   if(recordSCID < 1)
					{
					   continue;
					}
				   var statusB = record.前状态;
				   var statusA = record.后状态;
				 
				   //本星往当前星发
				   if(statusB == "1")
				   {
					   var lineObject = new StarLine(starSCID,recordSCID,time,time+1.5);
					   lineObject.timeDelta = timeRecordDelte;
					   lineObject.timeLimit = tableSE;
					   
					   starlines.add(lineObject,k);
				   }
				   else if(statusB == "2")
				   {
					   var lineObject = new StarLine(recordSCID,starSCID,time,time+1.5);
					   lineObject.timeDelta = timeRecordDelte;
					   lineObject.timeLimit = tableSE;
					   
					   starlines.add(lineObject,k);
				   }
				   if(statusA == "1")
				   {
					   var lineObject = new StarLine(starSCID,recordSCID,time+1.5,time+3.0);
					   lineObject.timeDelta = timeRecordDelte;
					   lineObject.timeLimit = tableSE;
					   
					   starlines.add(lineObject,k);
				   }
				   else if(statusA == "2")
				   {
					   var lineObject = new StarLine(recordSCID,starSCID,time+1.5,time+3.0);
					   lineObject.timeDelta = timeRecordDelte;
					   lineObject.timeLimit = tableSE;
					   
					   starlines.add(lineObject,k);
				   }
				   
					 time += timeStarDelta;    
				}
			}
			starlines.process();
			starlines.processDelta(j);	
		}
			
	}
	
</script>

</body>
</html>
